import axios from 'axios';
import qs from 'query-string';

export interface BizPayRecordId {
    id: number;
}

export interface BizPayRecord {
    id: number;
    user_id: number;
    biz_id: string;
    pay_price: number;
    pay_money: number;
    pay_status: number;
    paid_at: number;
    money: number;
    score: number;
    card_score: number;
    score_status: number;
    money_status: number;
    card_score_data: string;
    discount?: number;
    created_at: number;
    updated_at: number;
    // 关联数据
    user_phone?: string;
    biz_name?: string;
}

export interface BizPayRecordListRes {
    list: BizPayRecord[];
    total: number;
}

export interface BizPayRecordParams {
    current: number;
    pageSize: number;
    biz_id?: string; // 商家ID搜索
    user_phone?: string; // 用户手机号搜索
    pay_status?: number; // 支付状态筛选
    start_time?: string; // 开始时间
    end_time?: string; // 结束时间
}

/**
 * 获取商家支付记录列表
 * @param params
 */
export function queryBizPayRecordList(params: BizPayRecordParams) {
    return axios.get<BizPayRecordListRes>('/admin/bizPayRecord/index', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 获取商家支付记录详情
 * @param params
 */
export function queryBizPayRecordOne(params: BizPayRecordId) {
    return axios.get<BizPayRecord>('/admin/bizPayRecord/detail', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 删除商家支付记录
 * @param id
 */
export function delBizPayRecord(id: number) {
    return axios.post('/admin/bizPayRecord/delete', { id });
} 